package com.lagou.edu.controller;


import com.lagou.edu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/register/{email}/{password}/{code}")
    public Integer createUser(@PathVariable("email") String email, @PathVariable("password") String password,
                              @PathVariable("code") String code) {
        return userService.registerUser(email, password, code);
    }

    @GetMapping({"/login/{email}/{password}"})
    public Boolean loginUser(@PathVariable("email") String email, @PathVariable("password") String password){
        return userService.loginUser(email, password);
    }
}